//
//  SISSMineHouseCell.m
//  SISSAPP
//
//  Created by 优房网 on 2017/5/23.
//  Copyright © 2017年 优房网. All rights reserved.
//

#import "SISSMineHouseCell.h"


@interface SISSMineHouseCell ()

@property (strong, nonatomic) IBOutletCollection(UILabel) NSArray *markLabels;

@property (weak, nonatomic) IBOutlet UILabel *neighbourhoodAndPriceLabel;
@property (weak, nonatomic) IBOutlet UILabel *regionAreaTypeLabel;
@property (weak, nonatomic) IBOutlet NSLayoutConstraint *labelsViewHeight;
@property (weak, nonatomic) IBOutlet UILabel *visibleLabel;
@property (weak, nonatomic) IBOutlet UILabel *tagLabel;


@end
@implementation SISSMineHouseCell

- (void)awakeFromNib {
    [super awakeFromNib];
    
    self.visibleLabel.hidden = YES;
    self.visibleLabel.text = @"";
    
    for (UILabel *label in self.markLabels) {
        
        label.hidden = YES;
    }
    self.labelsViewHeight.constant = 1;
}

- (void)setHouseResourceModel:(SISSHouseResourceModel *)houseResourceModel {
    _houseResourceModel = houseResourceModel;
    
    self.neighbourhoodAndPriceLabel.text = [NSString stringWithFormat:@"%@ | %.f万",houseResourceModel.neighbourhood,[houseResourceModel.price floatValue]];
    
    self.regionAreaTypeLabel.text = [NSString stringWithFormat:@"%@-%@ | %@㎡ | %@",houseResourceModel.region,houseResourceModel.regionDetail,houseResourceModel.area,houseResourceModel.houseType];
    
    NSString *tagStr;
    UIColor *tagColor;
    switch (houseResourceModel.business_status) {
        case 0:
            tagStr = @"等待确认";
            tagColor = COLOR(0xAEC1D9);
            break;
            
        case 1:
            tagStr = @"已确认";
            tagColor = COLOR(0x334A60);
            break;
            
        case 2:
            tagStr = @"已拒绝";
            tagColor = COLOR(0xFF1F1D);
            break;
            
        default:
            break;
    }
    
    self.tagLabel.textColor = tagColor;
    self.tagLabel.text = tagStr;
    
    UIColor *color = houseResourceModel.read == 1 ? [UIColor grayColor] : COLOR(0x334A60);
    self.neighbourhoodAndPriceLabel.textColor = color;
    self.regionAreaTypeLabel.textColor = color;
    
    
    if (houseResourceModel.listTag.count > 0) {
        self.labelsViewHeight.constant = 30;
    } else {
        self.labelsViewHeight.constant = 1;
    }
    
    NSArray<UIColor *> *labelCololors = @[COLOR(0x33B189), COLOR(0xF76D81), COLOR(0x8E7FFF), COLOR(0x59ABFD), COLOR(0xE46B00)];
    
    for (UILabel *label in self.markLabels) {
        
        label.hidden = YES;
    }
    
    for (int i = 0; i < houseResourceModel.listTag.count; i++) {
        UILabel *label = self.markLabels[i];
        if ([houseResourceModel.listTag[i].tag isEqualToString:@""]) continue;
        label.hidden = NO;
        label.layer.borderWidth = 1;
        label.text = [NSString stringWithFormat:@" %@ ",houseResourceModel.listTag[i].tag];
        NSInteger colorIndex = houseResourceModel.listTag[i].color - 1;
        label.layer.borderColor = labelCololors[colorIndex].CGColor;
        label.textColor = labelCololors[colorIndex];
        label.layer.cornerRadius = 2;
        label.layer.masksToBounds = YES;
    }
    
}

- (void)setHouseCooperationModel:(SISSHouseCooperationModel *)houseCooperationModel {
    _houseCooperationModel = houseCooperationModel;
    
    self.neighbourhoodAndPriceLabel.text = [NSString stringWithFormat:@"%@ | %@万",houseCooperationModel.neighbourhood,houseCooperationModel.price];
    
    self.regionAreaTypeLabel.text = [NSString stringWithFormat:@"%@-%@ | %@㎡ | %@",houseCooperationModel.region,houseCooperationModel.regionDetail,houseCooperationModel.area,houseCooperationModel.houseType];
    
    self.tagLabel.backgroundColor = COLOR(0xFF1F1D);
    self.tagLabel.textColor = [UIColor whiteColor];
    self.tagLabel.layer.cornerRadius = 6;
    self.tagLabel.layer.masksToBounds = YES;
    self.tagLabel.text = houseCooperationModel.count ? [NSString stringWithFormat:@" %zd ",houseCooperationModel.count] : @"";
    
    //    if (houseCooperationModel.read == 1) {
    //        self.neighbourhoodAndPriceLabel.textColor = [UIColor grayColor];
    //        self.regionAreaTypeLabel.textColor = [UIColor grayColor];
    //    }
    
    if (houseCooperationModel.listTag.count > 0) {
        self.labelsViewHeight.constant = 30;
    } else {
        self.labelsViewHeight.constant = 1;
    }
    
    NSArray<UIColor *> *labelCololors = @[COLOR(0x33B189), COLOR(0xF76D81), COLOR(0x8E7FFF), COLOR(0x59ABFD), COLOR(0xE46B00)];
    
    for (UILabel *label in self.markLabels) {
        
        label.hidden = YES;
    }
    for (int i = 0; i < houseCooperationModel.listTag.count; i++) {
        UILabel *label = self.markLabels[i];
        if ([houseCooperationModel.listTag[i].tag isEqualToString:@""]) continue;
        label.hidden = NO;
        label.layer.borderWidth = 1;
        label.text = [NSString stringWithFormat:@" %@ ",houseCooperationModel.listTag[i].tag];
        NSInteger colorIndex = houseCooperationModel.listTag[i].color - 1;
        label.layer.borderColor = labelCololors[colorIndex].CGColor;
        label.textColor = labelCololors[colorIndex];
        label.layer.cornerRadius = 2;
        label.layer.masksToBounds = YES;
    }
    
}



@end
